﻿CREATE PROCEDURE [ServiceEngine].[UpdateEndpointUddiAssociation]	
	@EndpointID uniqueidentifier,
	@RuntimeServerID uniqueidentifier,
	@WsdlUrl nvarchar(400),
	@BindingUrl nvarchar(400)
AS
BEGIN
	DECLARE @ErrorMessage NVARCHAR(4000);
	DECLARE @ErrorSeverity INT;
	DECLARE @ErrorState INT;
	SET NOCOUNT ON;

	BEGIN TRY
		BEGIN TRANSACTION

		DECLARE @ID as uniqueidentifier

		SET @ID = newid();

		UPDATE [ServiceEngine].[Endpoints_AssociatedUddi]
	    SET 
		  [UddiWsdlUrl] = @WsdlUrl
		  ,[UddiBindingUrl] = @BindingUrl
	    WHERE
			EndpointID = @EndpointID AND 
			RuntimeServerID = @RuntimeServerID
		COMMIT TRANSACTION
	END TRY
	BEGIN CATCH
		SELECT 
			@ErrorMessage = ERROR_MESSAGE(),
			@ErrorSeverity = ERROR_SEVERITY(),
			@ErrorState = ERROR_STATE();

		IF XACT_STATE() <> 0 ROLLBACK TRANSACTION;

		RAISERROR (@ErrorMessage, 
				   @ErrorSeverity,
				   1);
	END CATCH
END


